% Paper: E- Monetary Theory  (2nd edition)
% Author: Duong Ngotran
% Graph: Crisis - Large scale asset purchase

%----------------------------------------------------------------------------
% Some Parameters
%----------------------------------------------------------------------------
T = 301;    %Number of periods 
var_foc = 29;      % Number of variables in one period
pos_value = 3;     % Position of var_value in A
truc = (-1):(T-2);         % Horizontal axis when drawing with level
spline_truc = (-1):(1/4):(T-2);     %Horizontal axis when drawing with spline 
size_struc = 1201;  % size of spline truc
deltab = 0.5;

%----------------------------------------------------------------------------
% ZLB during 20 periods then raise IOR
%----------------------------------------------------------------------------
filename= 'EMT_LSAP_zlb_duration_20.txt';
[ rf_t, rh_t, rrf_t, AP_S, mapp, s_growth_M, tau_t, s_agg_c ] = lsap_zlb_duration( filename );
rf_20= rf_t;
rh_20= rh_t;
rrf_20 = rrf_t;
ql_20= AP_S(mapp('ql'),:);
pie_20= AP_S(mapp('pie'),:);
y_20 = AP_S(mapp('y'),:);
gm_20 = s_growth_M;
m_20 = AP_S(mapp('m'),:);
tau_20 = tau_t;
aggc_20 = s_agg_c;

%----------------------------------------------------------------------------
% ZLB during 20 then raise IOR and apply MS rule
%----------------------------------------------------------------------------
filename= 'EMT_ms_rule_raise_rn.txt';
[ rf_t, rh_t, rrf_t, AP_S, mapp, s_growth_M, tau_t, s_agg_c ] = lsap_zlb_duration( filename );
rf_ms= rf_t;
rh_ms= rh_t;
rrf_ms = rrf_t;
ql_ms= AP_S(mapp('ql'),:);
pie_ms= AP_S(mapp('pie'),:);
y_ms = AP_S(mapp('y'),:);
gm_ms = s_growth_M;
m_ms = AP_S(mapp('m'),:);
tau_ms = tau_t;
aggc_ms = s_agg_c;

%----------------------------------------------------------------------------
%Figure
%----------------------------------------------------------------------------
set(groot, 'DefaultLegendInterpreter', 'latex');

figure('Name', 'Federal Funds Rate');
plot(truc, rf_ms, truc, rf_20);
leg = legend('$R^f$ - MS rule', '$R^f$ - LSAP20', 'location', 'best');

figure('Name', 'Money Supply');
plot(spline_truc, m_ms, spline_truc, m_20);
leg = legend('$m$ - MS rule', '$m$ - LSAP20', 'location', 'best');

figure('Name', 'Inflation');
plot(spline_truc, pie_ms, spline_truc, pie_20);
leg = legend('$m$ - MS rule', '$m$ - LSAP20', 'location', 'best');

figure('Name', 'Output');
plot(spline_truc, y_ms, spline_truc, y_20);
leg = legend('$y$ - MS rule', '$y$ - LSAP20', 'location', 'best');

figure('Name', 'Money drop');
plot(truc, tau_ms, truc, tau_20);
leg = legend('$\tau$ - MS rule', '$\tau$ - LSAP20', 'location', 'best');



        
        
        
        
        
        
        